package com.reebake.ideal.security.config;

import cn.hutool.core.util.ArrayUtil;
import com.reebake.ideal.security.properties.ClientSecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;

@Configuration
@EnableWebSecurity
@EnableMethodSecurity(jsr250Enabled = true, securedEnabled = true)
public class BasicClientSecurityConfig {
	
	@Autowired
	private ClientSecurityProperties clientSecurityProperties;
	
	@Bean
	WebSecurityCustomizer webSecurityCustomizer() {
		return (web) -> web.ignoring().requestMatchers(ArrayUtil.toArray(clientSecurityProperties.getIgnored(), String.class));
	}

}
